Problem Challenge 2

Path with Maximum Sum (hard) #

Find the path with the maximum sum in a given binary tree. Write a function that returns the maximum sum. A path can be defined as a sequence of nodes between any two nodes and doesn’t necessarily pass through the root.

Created with Fabric.js 1.6.0-rc.1 Example 1: 1 2 3 4 5 6 Output: 16Explanation: The path with maximum sum is: [4, 2, 1, 3, 6]
Created with Fabric.js 1.6.0-rc.1 Example 2: 1 2 3 1 3 5 6 7 8 9 Output: 31Explanation: The path with maximum sum is: [8, 5, 3, 6, 9]

Try it yourself #

Try solving this question here:

Output

0.483s

Maximum Path Sum: -1 Maximum Path Sum: -1 Maximum Path Sum: -1

Mark as Completed
←    Back
Solution Review: Problem Challenge 1
Next    →
Solution Review: Problem Challenge 2